package com.yellowpage.sample.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.yellowpage.white.common.Constants;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import com.yellowpage.sample.data.HtmlTemplate;
import com.yellowpage.sample.dao.HtmlTemplateDao;

public class HtmlTemplateServiceImpl extends BaseServiceImpl implements HtmlTemplateService {
	  private HtmlTemplateDao htmlTemplateDao;
	
	  public void setHtmlTemplateDao(HtmlTemplateDao htmlTemplateDao) {
		  this.htmlTemplateDao = htmlTemplateDao;
	  }
	
	
	  /* White generate Method */ 
	  public HtmlTemplate getHtmlTemplate(Long id){
	      return htmlTemplateDao.get(id);
	  }
	  
    public List<HtmlTemplate> getAllHtmlTemplate(){
        return htmlTemplateDao.getAll();
    }
    
    public List<Map> queryHtmlTemplateByPage(Map queryMap, PageRender pageRender) {		
        
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.HTML_TEMPLATE_ID , a.RESOURCE_ID , a.CREATE_TIME , a.CREATE_USER , a.LAST_UPDATE_TIME , a.LAST_UPDATE_USER , a.NAME , a.TYPE , a.STATUS    FROM WEB_HTML_TEMPLATE a WHERE 1=1 ")
				    			.addCondition(" and HTML_TEMPLATE_ID = :htmlTemplateId ")
							    			.addCondition(" and RESOURCE_ID = :resourceId ")
							    		    .addCondition(" and CREATE_TIME = to_date(:createTime ,'yyyy-MM-dd') ")
		    				    			.addCondition(" and CREATE_USER = :createUser ")
							    		    .addCondition(" and LAST_UPDATE_TIME = to_date(:lastUpdateTime ,'yyyy-MM-dd') ")
		    				    			.addCondition(" and LAST_UPDATE_USER = :lastUpdateUser ")
							    			.addCondition(" and NAME = :name ")
							    			.addCondition(" and TYPE = :type ")
							    			.addCondition(" and STATUS = :status ")
							    ; 	

		List<Map> resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);

		return resultList;
	}
    
    
    public void saveHtmlTemplate(HtmlTemplate htmlTemplate){
        htmlTemplateDao.save(htmlTemplate);
    }
    
	  public void updateHtmlTemplate(HtmlTemplate htmlTemplate){
	      htmlTemplateDao.update(htmlTemplate);
	  }
	  
	  public void delete(List deleteList){
	      htmlTemplateDao.remove(deleteList);
	  }
	  
	  
	 
	
}	